package fr.umlv.m2.recipes.ideas;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

/**
 * Create the Splash Activity view uses to generate a splashscreen
 * @author Christophe Chillan
 *
 */
public class Splash extends Activity {
	// time in milliseconds
	private boolean active = true;
	private static final long SPLASHTIME = 3000;


	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle icicle) {
		super.onCreate(icicle);
		setContentView(R.layout.splash);
		Thread splashTread = new Thread() {
	        @Override
	        public void run() {
	            try {
	                int waited = 0;
	                while(active && (waited < SPLASHTIME)) {
	                    sleep(100);
	                    if(active) {
	                        waited += 100;
	                    }
	                }
	            } catch(InterruptedException e) {
	                // do nothing
	            } finally {
	                finish();
	                startActivity(new Intent(Splash.this, MenuTabWidget.class));
	                interrupt();
	            }
	        }
	    };
		
		splashTread.start();
	}
}